<?php
declare(strict_types=1);

namespace app\admin\model;

use think\Model;
/**
 * @mixin \think\Model
 */
class Weblog extends Model
{
    protected $schema = [
        'id' => 'bigint',
        'content' => 'varchar',
        'create_time' => 'datetime',
        'log_type' => 'char',
        'ipaddress' => 'varchar'
    ];
    protected $mapping = [
        'create_time' => 'createTime',
        'log_type' => 'logType'
    ];

    protected $logtype = [
        '1' => '进入网站',
        '2' => '首页',
        '3' => '必需品',
        '4' => '笔记',
        '5' => '小李档案'
    ];
    public function getLogtypeAttr($value)
    {
        return $this->logtype[$value];
    }

    public function getMappedField($field)
    {
        $mapping = array_search($field, $this->mapping);
        return $mapping ?? $field;
    }

    public function getTypeField()
    {
        return $this->logtype;
    }
}
